var app = getApp();
var ApiUrl = app.globalData.ApiUrl;
var app = getApp();
var page = 10;
var key = "";

var loadMore = function (that) {

  key = that.data.key?that.data.key:wx.getStorageSync('key');
  if (that.data.order_group_list) {
    var listBefore = that.data.order_group_list;
  } else {
    var listBefore = new Array();
  }
  that.setData({
    showLoading: false
  });

  wx.request({
    url: ApiUrl + "/index.php?act=member_refund&op=get_refund_list&page=10&curpage=" + that.data.curpage,
    data: {
      'key': key,     
    },
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
    success: function (res) {

      var refund_list = res.data.datas.refund_list;
    
      var curpage = that.data.curpage + 1;
      that.setData({
        refund_list: listBefore.concat(refund_list),//listBefore.concat(ordergroup),    
        page_total: res.data.page_total,
        showLoading: true,
        hasmore: res.data.hasmore,
        curpage: curpage,
        key: key
      });

    },
  });
}

 
Page({

  /**
   * 页面的初始数据
   */
  data: {
    showLoading: true,
    scrollHeight: 0,
    scrollTop: 0
  },
  
  onLoad: function (options) {
    key = wx.getStorageSync('key');
    var that = this;
    var curpage = 1;
    wx.getSystemInfo({
      success: function (result) {
        that.setData({
          scrollHeight: result.windowHeight,
          curpage: curpage,
          key: key
        });

        if (key) {
          loadMore(that);
        } else {
          wx.reLaunch({
            url: '/pages/index/index',
          })
           
        }
      },
    });
  },
})